<?php

namespace App\Extensions\Grid\Displayers;

use Encore\Admin\Grid\Displayers\AbstractDisplayer;

class Nowrap extends AbstractDisplayer
{
    public function display($minWidth = '',$width='')
    {
        $style = 'white-space:normal;';
        if($width){
            $style .= "width: {$width}px;max-width: {$width}px;min-width: {$width}px;";
        }elseif($minWidth){
            $style .= "min-width: {$minWidth}px;";
        }
        $this->getColumn()->style($style);
        return $this->value;
    }
    protected function normal($value,$title,$width)
    {
        return <<<THML
<a href="javascript:void(0);" class="grid-column-help" data-toggle="tooltip" data-title="{$title}" data-placement="right" data-html="true"
 style="display: inline-block;white-space:normal;width:{$width};min-width: {$width};max-width: {$width}">{$value}
</a>
THML;
    }

    protected function nowrap($title,$width): string
    {
        return <<<THML
<a href="javascript:void(0);" class="grid-column-help" data-toggle="tooltip" data-title="{$title}" data-placement="right" data-html="true"
style="display: inline-block; width: {$width}px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;"
>{$this->value}
</a>
THML;
    }
}
